package me.pplay.playtalk.protocol;

import java.io.Serializable;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

import me.pplay.playtalk.protocol.bean.AuthServeripData;
import me.pplay.playtalk.protocol.bean.BmpData;
import me.pplay.playtalk.protocol.bean.KeyValue;
import me.pplay.playtalk.protocol.bean.RspData;
import me.pplay.playtalk.protocol.bean.SendNode;
import me.pplay.playtalk.protocol.bean.TPBuddyinfo;
import me.pplay.playtalk.protocol.bean.TpPacket;
import me.pplay.playtalk.service.PlayTalkService;
import me.pplay.playtalk.util.LogManager;
import me.pplay.playtalk.util.SkyUtil;
import me.pplay.playtalk.util.UserInfo;
import android.content.Context;
import android.os.Bundle;
import android.os.Message;
import android.util.Base64;

public class TpAuth extends ProtocolPacket {
	public static final String BROADCASTACTION_TPAUTH = "me.pplay.playtalk.tpauth";
	public static final int ENUM_GETPWD_MAIL = 1;
	public static final int ENUM_GETPWD_PHONE = 2;
	public static final int ENUM_GETPWD_QA = 3; 
	public static final int ENUM_CHPWDPROTECTION_MODIFY = 1;
	public static final int ENUM_CHPWDPROTECTION_ADD = 2;
	public static final int AUTH_SIGIN_IMPLICIT_OK = 0; // 隐藏登录成功
	public static final int AUTH_SIGIN_IMPLICIT_ERR = 1;
	public static final int AUTH_SIGIN_IMPLICIT_TIMEOUT = 2;
	public static final int AUTH_SIGIN_EXPLICIT_OK = 3; // 通过用户名密码登录成功
	public static final int AUTH_SIGIN_EXPLICIT_ERR = 4;
	public static final int AUTH_SIGIN_EXLICIT_TIMEOUT = 5;
	public static final int AUTH_SIGUP_IMPLICIT_OK = 6; // /隐藏注册成功即通过imsi获取skyid需要app保存该skyid
	public static final int AUTH_SIGUP_IMPLICIT_ERR = 7;
	public static final int AUTH_SIGUP_IMPLICIT_TIMEOUT = 8;
	public static final int AUTH_SIGUP_EXPLICIT_OK = 9; // 通过用户名密码等属性注册成功
	public static final int AUTH_SIGUP_EXPLICIT_ERR = 10;
	public static final int AUTH_SIGUP_EXLICIT_TIMEOUT = 11;
	public static final int AUTH_SIGIN_EXPLICIT_WAITING = 12; // 通过用户名密码登录时需要用户验证图标
	public static final int AUTH_GETSKYID_OK = 13; // 如果是显式登录或者隐藏登录或者显示注册并且没有skyid的话有可能会返回该错误
	public static final int AUTH_GETSKYID_ERR = 14; // 如果是隐藏登录或者注册的话有可能会返回该错误
	public static final int AUTH_SETPWDPROTECTION_OK = 15; // 设置密保
	public static final int AUTH_SETPWDPROTECTION_ERR = 16;
	public static final int AUTH_SETPWDPROTECTION_TIMEOUT = 17;
	public static final int AUTH_GETPWDPROTECTION_OK = 18; // 获取密保问题列表
	public static final int AUTH_GETPWDPROTECTION_ERR = 19;
	public static final int AUTH_GETPWDPROTECTION_TIMEOUT = 20;
	public static final int AUTH_GETPWDPROTECTIONTYPE_OK = 21; // 获取密保类型
	public static final int AUTH_GETPWDPROTECTIONTYPE_ERR = 22;
	public static final int AUTH_GETPWDPROTECTIONTYPE_TIMEOUT = 23;
	public static final int AUTH_CHANGEPWDPROTECTION_OK = 24; // 修改密保
	public static final int AUTH_CHANGEPWDPROTECTION_ERR = 25;
	public static final int AUTH_CHANGEPWDPROTECTION_TIMEOUT = 26;
	public static final int AUTH_GETPWD_OK = 27;
	public static final int AUTH_GETPWD_ERR = 28;
	public static final int AUTH_GETPWD_TIMEOUT = 29;
	public static final int AUTH_CHANGEPWD_OK = 30;
	public static final int AUTH_CHANGEPWD_ERR = 31;
	public static final int AUTH_CHANGEPWD_TIMEOUT = 32;
	public static final int AUTH_TIMEROUT_ERR = 33;
	public static final int AUTH_UNKOWN_ERR = 34;
	public static final int AUTH_NETWORK_ERR = 35;
	public static final int AUTH_SETICONSTRING_OK = 36;
	public static final int AUTH_SESSIONID_ERR = 37;
	public static final int AUTH_GETPWDPROTECTION_ME_OK = 38; // 获取自己密保问题列表
	public static final int AUTH_GETPWDPROTECTION_ME_ERR = 39;
	public static final int AUTH_GETPWDPROTECTION_ME_TIMEOUT = 40;
	private boolean isRun = false;
	private int skyid = 0;
	private int session_id = 0;
	private static final String url = "172.18.1.100";
	private static int port = 9301;
	SendNode nextnode = null;
	private String me_qstr = null;
	private String me_email = null;
	private Context context;
	private Map<Integer, DataCallBack> callBackMap = new HashMap<Integer, DataCallBack>();
	private LinkedList<String> pwdprotection_list = new LinkedList<String>();
	private String[] tips = {"","","","",""};
	private static final int AUTH_CMD_SIGIN_IMPLICIT = 0;
	private static final int AUTH_CMD_SIGIN_EXPLICIT = 1;
	private static final int AUTH_CMD_SETPWDPROTECTION = 2;// 设置密保
	private static final int AUTH_CMD_GETPWDPROTECTION = 3;// 获取密保问题列表
	private static final int AUTH_CMD_CHANGEPWDPROTECTION = 4;// 修改密保
	private static final int AUTH_CMD_SETICONSTRING = 5;
	private static final int AUTH_CMD_GETPWD = 6;
	private static final int AUTH_CMD_CHANGEPWD = 7;
	private static final int AUTH_CMD_SIGUP_IMPLICIT = 8;
	private static final int AUTH_CMD_SIGUP_EXPLICIT = 9;
	private static final int AUTH_CMD_GETPWDPROTECTION_ME=10;
	public void setContext(Context context) {
		this.context = context;
	}

	public TpAuth() {
		// funcmap.put
		ProtocolList sendlist = new ProtocolList();
		setProtocolPacketSendList(sendlist);
		SET_TP_FLAG(TP_NEED_RECORD);
		setNeed_bytes((short) TP_PACKET_HDRLEN);
	}

	@Override
	public void tp_keeplive() {
		// TODO Auto-generated method stub

	}

	public void tp_setcallback(int cmd, DataCallBack callback) {
		callBackMap.put(cmd, callback);
	}

	@Override
	public void tp_recvcb(int result, TpPacket pkt, SendNode node) {
		LogManager.LogShow("TpAuth", "tp_recvcb resulut = " + result);
		switch (result) {
		case ProtocolType.TP_ERRCODE_ERR_SERVER:
		case ProtocolType.TP_ERRCODE_ERR_TPVERSION:
			// case TP_ERRCODE_ERR_SOCKETCLOSE:
		case ProtocolType.TP_ERRCODE_ERR_SOCKETDATAERR:
		case ProtocolType.TP_ERRCODE_ERR_SOCKET:
		case ProtocolType.TP_ERRCODE_ERR_SOCKETRECV:
		case ProtocolType.TP_ERRCODE_ERR_SOCKETSEND:
		case ProtocolType.TP_ERRCODE_ERR_SOCKETCONNECT:
//		case ProtocolType.TP_ERRCODE_ERR_TIMEOUT:
			Callback(AUTH_NETWORK_ERR, null, null);
			break;
			
		case ProtocolType.TP_ERRCODE_ERR_TIMEOUT:
		{
			RspData rspdata = new RspData();
			rspdata.setSubid(node.getCmd());
			Callback(AUTH_TIMEROUT_ERR, rspdata, null);
		}
		break;
		case ProtocolType.TP_ERRCODE_OK: {
			auth_packet_process(pkt);
		}
			break;
		}
	}

	@Override
	public boolean tp_sendcb(int cmd, SendNode nodedata) {
		TpPacket pkt = new TpPacket();
		pkt.setService(ProtocolType.ServerId.TP_SERVICE_AUTH);
		pkt.setSubid((short) nodedata.getCmd());
		pkt.setStatus((short) 0);
		pkt.setId(nodedata.getSession_id());
		this.session_id = nodedata.getSession_id();
		return tp_send_packetex(pkt, null, this.skyid, nodedata.getData(), nodedata.getDatalen());
	}

	public void tp_auth_start() {
		if (!isRun) {
			isRun = true;
			this.tp_data_starturl(url, port);
		}
	}

	public void tp_auth_stop() {
		isRun = false;
		skyid = 0;
		nextnode = null;
		me_qstr = null;
		me_email = null;
		callBackMap.clear();
		pwdprotection_list.clear();
		tp_data_stop();
	}

	public void tp_auth_signup_explicit(String username, String password, TPBuddyinfo buddyinfo, int skyid, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SIGUP_EXPLICIT, callback);
		tp_auth_signup_explicit(username, password, buddyinfo, skyid);
	}

	public void tp_auth_signup_explicit(String username, String password, TPBuddyinfo buddyinfo, int skyid) {
		LogManager.LogShow("TpAuth", "tp_auth_signup_explicit username = " + username + "password = " + password);
		String pwd = SkyUtil.Base64encode(password);
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_user, username);
		map.put(ProtocolType.Key.TP_TAG_sex, "" + buddyinfo.getSex());
		map.put(ProtocolType.Key.TP_TAG_birth, buddyinfo.getBirthday());
		map.put(ProtocolType.Key.TP_TAG_mcc, buddyinfo.getCountry());
		map.put(ProtocolType.Key.TP_TAG_sign, buddyinfo.getSignature());
		map.put(ProtocolType.Key.TP_TAG_pnum, buddyinfo.getPnum());
		map.put(ProtocolType.Key.TP_TAG_pwd, pwd);
		
		map.put(ProtocolType.Key.TP_TAG_hsman, UserInfo.getHsman());
		map.put(ProtocolType.Key.TP_TAG_hstype, UserInfo.getHstype());
		map.put(ProtocolType.Key.TP_TAG_imsi, UserInfo.getImsi());
		map.put(ProtocolType.Key.TP_TAG_imei, UserInfo.getImei());
		map.put(ProtocolType.Key.TP_TAG_mem, "" + UserInfo.getMem());
		map.put(ProtocolType.Key.TP_TAG_vmver, "" + UserInfo.getCurrentapiVersion());
		map.put(ProtocolType.Key.TP_TAG_qusiontype, "" + 2);
		// map.put(ProtocolType.Key.TP_TAG_et,SCREEN_ENTRY);
		map.put(ProtocolType.Key.TP_TAG_hsver, "460000123456789");
		map.put(ProtocolType.Key.TP_TAG_w, "" + UserInfo.getSrcw());
		map.put(ProtocolType.Key.TP_TAG_h, "" + UserInfo.getSrch());
		map.put(ProtocolType.Key.TP_TAG_appid, "" + UserInfo.getAppid());
		map.put(ProtocolType.Key.TP_TAG_appver, "" + UserInfo.getAppver());
		map.put(ProtocolType.Key.TP_TAG_lan, UserInfo.getLang());
		
		data = tp_packet_putdata(map);
		this.skyid = skyid;
		if(skyid==0&&UserInfo.getImsi().substring(0, 3).equals("999")){//no imsi
			;
		}else if (0 == skyid) {
			tp_auth_signup_implicit(null);
			this.nextnode = tp_auth_get_nextsendnode(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNUP, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGUP_EXPLICIT));
			return;
		}
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNUP, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGUP_EXPLICIT));

	}

	public void tp_auth_signup_implicit(DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SIGUP_IMPLICIT, callback);
		tp_auth_signup_implicit();
	}
	public void tp_auth_get_tips_template()
	{
		LogManager.LogShow("TpAuth", "tp_auth_get_tips_template");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_lan, UserInfo.getLang());
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETTIPTEMPLATE, 0 * 1000, data, null);		
	}
	public String[] tp_auth_get_tips_data()
	{
		if(tips[0].equals(""))
			tp_auth_get_tips_template();
		return tips;
	}
	public void tp_auth_signup_implicit() {
		LogManager.LogShow("TpAuth", "tp_auth_signup_implicit");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_hsman, UserInfo.getHsman());
		map.put(ProtocolType.Key.TP_TAG_hstype, UserInfo.getHstype());
		map.put(ProtocolType.Key.TP_TAG_imsi, UserInfo.getImsi());
		map.put(ProtocolType.Key.TP_TAG_imei, UserInfo.getImei());
		// map.put(ProtocolType.Key.TP_TAG_imsi, "460000123456789");
		// map.put(ProtocolType.Key.TP_TAG_imei, "460000123456789");
		map.put(ProtocolType.Key.TP_TAG_mem, "" + UserInfo.getMem());
		map.put(ProtocolType.Key.TP_TAG_vmver, "" + UserInfo.getCurrentapiVersion());
		map.put(ProtocolType.Key.TP_TAG_plat, "" + 10);
		// map.put(ProtocolType.Key.TP_TAG_et,SCREEN_ENTRY);
		map.put(ProtocolType.Key.TP_TAG_hsver, "460000123456789" );
		map.put(ProtocolType.Key.TP_TAG_w, "" + UserInfo.getSrcw());
		map.put(ProtocolType.Key.TP_TAG_h, "" + UserInfo.getSrch());
		map.put(ProtocolType.Key.TP_TAG_appid, "" + UserInfo.getAppid());
		map.put(ProtocolType.Key.TP_TAG_appver, "" + UserInfo.getAppver());
		map.put(ProtocolType.Key.TP_TAG_lan, UserInfo.getLang());
//		map.put("lanstr", UserInfo.getLang());
		data = tp_packet_putdata(map);
		this.skyid = 0;
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETSKYID, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGUP_IMPLICIT));

	}

	public void tp_auth_signin_implicit(int skyid, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SIGIN_IMPLICIT, callback);
		tp_auth_signin_implicit(skyid);
	}

	public void tp_auth_signin_implicit(int skyid) {
		this.skyid = skyid;
		LogManager.LogShow("TpAuth", "tp_auth_signin_implicit skyid = " + skyid + callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));
		if (0 != skyid && -1 != skyid) {
			tp_auth_signin_explicit("", "");
		} else {
			tp_auth_signup_implicit(callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));//没有skyid的话，登录需要先注册skyid
			byte[] data = tp_auth_get_signindata("", "");
			LogManager.LogShow("TpAuth", "nextnode = " + skyid + callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));
			this.nextnode = tp_auth_get_nextsendnode(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNIN, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));
			LogManager.LogShow("TpAuth", "nextnode = " + skyid + this.nextnode + callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));
		}
	}

	public void tp_auth_signin_explicit(String username, String password, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SIGIN_EXPLICIT, callback);
		tp_auth_signin_explicit(username, password);
	}

	public void tp_auth_signin_explicit(String username, String password) {
		LogManager.LogShow("TpAuth", "tp_auth_signin_explicit username = " + username + "password = " + password);
		byte[] data = tp_auth_get_signindata(username, password);
		//this.skyid = 0;
		if(username.equals(""))
			tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNIN, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT));
		else
			tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNIN, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SIGIN_EXPLICIT));
	}

	public void tp_auth_signin_set_iconstring(String iconstr, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SETICONSTRING, callback);
		tp_auth_signin_set_iconstring(iconstr);
	}

	public void tp_auth_signin_set_iconstring(String iconstr) {
		LogManager.LogShow("TpAuth", "tp_auth_signin_set_iconstring");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_aiconid, iconstr);
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETICONSTR, ProtocolType.TP_TIMOUT, data, null);
	}

	public void tp_auth_change_pwd(String user, String oldpwd, String newpwd, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_CHANGEPWD, callback);
		tp_auth_change_pwd(user, oldpwd, newpwd);
	}

	public void tp_auth_change_pwd(String user, String oldpwd, String newpwd) {
		LogManager.LogShow("TpAuth", "tp_auth_change_pwd");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_user, user);
		map.put(ProtocolType.Key.TP_TAG_pwd, oldpwd);
		map.put(ProtocolType.Key.TP_TAG_newpwd, newpwd);
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWD, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_CHANGEPWDPROTECTION));
	}

	public void tp_auth_get_pwdbymail(String user, String newPassword, String mailbox, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_GETPWD, callback);
		tp_auth_get_pwdbymail(user, newPassword, mailbox);
	}

	public void tp_auth_get_pwdbymail(String user, String newPassword, String mailbox) {
		tp_auth_get_pwd(ENUM_GETPWD_MAIL, user, "", mailbox, "", "", newPassword);
		return;
	}

	public void tp_auth_get_pwdbyphonenum(String user, String newPassword, String phone, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_GETPWD, callback);
		tp_auth_get_pwdbyphonenum(user, newPassword, phone);
	}

	public void tp_auth_get_pwdbyphonenum(String user, String newPassword, String phone) {
		tp_auth_get_pwd(ENUM_GETPWD_PHONE, user, phone, "", "", "", newPassword);
		return;
	}

	public void tp_auth_get_pwdbypwdprotection(String user, String newPassword, String question, String answer, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_GETPWD, callback);
		tp_auth_get_pwdbypwdprotection(user, newPassword, question, answer);
		return;
	}

	public void tp_auth_get_pwdbypwdprotection(String user, String newPassword, String question, String answer) {
		tp_auth_get_pwd(ENUM_GETPWD_QA, user, "", "", question, answer, newPassword);
		return;
	}

	public void tp_auth_set_pwdprotection(String username, String qstr, String astr, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_SETPWDPROTECTION, callback);
		tp_auth_set_pwdprotection(username, qstr, astr);
		return;
	}

	public void tp_auth_set_pwdprotection(String username, String qstr, String astr) {
		LogManager.LogShow("TpAuth", "tp_auth_set_pwdprotection");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_user, username);
		map.put(ProtocolType.Key.TP_TAG_qstr, qstr);
		map.put(ProtocolType.Key.TP_TAG_qstr, astr);
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETPWDPROTECTION, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_SETPWDPROTECTION));
	}

	public void tp_auth_change_pwdprotection(String username,String oldqstr, String oldastr, String newqstr, String newastr,String email, DataCallBack callback) {
		tp_setcallback(AUTH_CMD_CHANGEPWDPROTECTION, callback);
		tp_auth_change_pwdprotection(username,oldqstr, oldastr, newqstr, newastr,email);
	}

	// 密保问题添加和修改
	public void tp_auth_change_pwdprotection(String username,String oldqstr, String oldastr, String newqstr, String newastr,String email) {

		LogManager.LogShow("TpAuth", "tp_auth_set_pwdprotection");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		if (null == oldqstr) {// 密保问题添加
			map.put(ProtocolType.Key.TP_TAG_qusiontype, "" + ENUM_CHPWDPROTECTION_ADD);
			map.put(ProtocolType.Key.TP_TAG_newqstr, newqstr);
			map.put(ProtocolType.Key.TP_TAG_newastr, newastr);
			map.put(ProtocolType.Key.TP_TAG_email, email==null?"":email);
			map.put(ProtocolType.Key.TP_TAG_qstr, "");
			map.put(ProtocolType.Key.TP_TAG_astr, "");
			map.put(ProtocolType.Key.TP_TAG_user,username);
		} else {
			map.put(ProtocolType.Key.TP_TAG_qusiontype, "" + ENUM_CHPWDPROTECTION_MODIFY);
			map.put(ProtocolType.Key.TP_TAG_newqstr, newqstr);
			map.put(ProtocolType.Key.TP_TAG_newastr, newastr);
			map.put(ProtocolType.Key.TP_TAG_qstr, oldqstr);
			map.put(ProtocolType.Key.TP_TAG_astr, oldastr);
			map.put(ProtocolType.Key.TP_TAG_user,username);
		}
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWDPROTECTION, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_CHANGEPWDPROTECTION));

	}
	public void tp_auth_get_pwdprotection(DataCallBack callback)
	{
		LogManager.LogShow("TpAuth", "private tp_auth_get_pwdprotection");
		tp_setcallback(AUTH_CMD_GETPWDPROTECTION, callback);
		tp_auth_get_pwdprotection();
	}
	public LinkedList<String> tp_auth_get_pwdprotection_list()
	{//获取问题列表
		return pwdprotection_list;
	}
	public void tp_auth_get_pwdprotection()
	{
		LogManager.LogShow("TpAuth", "tp_auth_get_pwdprotection");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_lan, UserInfo.getLang());
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWDPROTECTION, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_GETPWDPROTECTION));
	}
	/* *< //请求获取个人密保问题. */
	public void tp_auth_get_pwdprotection_me(String user_name,DataCallBack callback) {
		LogManager.LogShow("TpAuth", "private tp_auth_get_pwdprotection_me");
		tp_setcallback(AUTH_CMD_GETPWDPROTECTION_ME, callback);
		tp_auth_get_pwdprotection_me(user_name);
	}
	public String tp_auth_get_pwdprotection_me_qstr()
	{
		return me_qstr;
	}
	public String tp_auth_get_pwdprotection_me_email()
	{
		return me_email;
	}
	public void tp_auth_get_pwdprotection_me(String user_name) {
		LogManager.LogShow("TpAuth", "tp_auth_get_pwdprotection_me");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_user, user_name);
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWDPROTECTION_ME, ProtocolType.TP_TIMOUT, data, null);
	}

	// 通过密保找回密码
	private void tp_auth_get_pwd(int type, String user, String phone, String mailbox, String question, String answer, String newPassword) {
		LogManager.LogShow("TpAuth", "private tp_auth_get_pwd");
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_protectiontype, "" + type);
		map.put(ProtocolType.Key.TP_TAG_pnum, phone == null ? "" : phone);
		map.put(ProtocolType.Key.TP_TAG_email, mailbox == null ? "" : mailbox);
		map.put(ProtocolType.Key.TP_TAG_qstr, question == null ? "" : question);
		map.put(ProtocolType.Key.TP_TAG_astr, answer == null ? "" : answer);
		map.put(ProtocolType.Key.TP_TAG_user, user == null ? "" : user);
		map.put(ProtocolType.Key.TP_TAG_newpwd, newPassword == null ? "" : newPassword);
		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn(ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWD, ProtocolType.TP_TIMOUT, data, callBackMap.get(AUTH_CMD_GETPWD));
	}

	private void CallbackBroadCast(int result, RspData resultdata, Object obj) {
//		 Intent intent = new Intent();
//		 intent.setAction(BROADCASTACTION_TPAUTH);
//		 intent.putExtra("result", result);
//		 intent.putExtra("resultdata", resultdata);
//		 intent.putExtra("object", (Serializable) obj);
//		 context.sendBroadcast(intent);
		 
			Message msg = new Message();
			msg.what = result;
			Bundle bundle = new Bundle();
			bundle.putInt("result", result);
			bundle.putSerializable("resultdata", resultdata);
			bundle.putSerializable("object", (Serializable) obj);
			msg.setData(bundle);
			PlayTalkService.getInstance().serviceHandler.sendMessage(msg);
			
			
	}

	private void Callback(int result, RspData resultdata, Object obj) {
		LogManager.LogShow("TpAuth", "Callback = " + result);
		switch (result) {
		case AUTH_GETSKYID_ERR:
		case AUTH_GETSKYID_OK:
		case AUTH_NETWORK_ERR:
		case AUTH_TIMEROUT_ERR:
		case AUTH_UNKOWN_ERR: {
			ProtocolList list = getProtocolPacketSendList();
			if (list != null) {
				SendNode sendnode = list.tp_data_firstnode();
				if (sendnode!=null&&sendnode.getCallBack() != null) {
					sendnode.getCallBack().Callback(result, resultdata, obj);
				}
			}
		}
			break;
		case AUTH_SIGUP_IMPLICIT_OK:
		case AUTH_SIGUP_IMPLICIT_ERR:
		case AUTH_SIGUP_IMPLICIT_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_SIGUP_IMPLICIT) != null) {
				callBackMap.get(AUTH_CMD_SIGUP_IMPLICIT).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_SIGUP_EXPLICIT_OK:
		case AUTH_SIGUP_EXPLICIT_ERR:
		case AUTH_SIGUP_EXLICIT_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_SIGUP_EXPLICIT) != null) {
				callBackMap.get(AUTH_CMD_SIGUP_EXPLICIT).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_SIGIN_IMPLICIT_OK:
		case AUTH_SIGIN_IMPLICIT_ERR:
		case AUTH_SIGIN_IMPLICIT_TIMEOUT:
		case AUTH_SIGIN_EXPLICIT_WAITING:
			if (callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT) != null) {
				callBackMap.get(AUTH_CMD_SIGIN_IMPLICIT).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_SIGIN_EXPLICIT_OK:
		case AUTH_SIGIN_EXPLICIT_ERR:
		case AUTH_SIGIN_EXLICIT_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_SIGIN_EXPLICIT) != null) {
				callBackMap.get(AUTH_CMD_SIGIN_EXPLICIT).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_SETPWDPROTECTION_OK:
		case AUTH_SETPWDPROTECTION_ERR:
		case AUTH_SETPWDPROTECTION_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_SETPWDPROTECTION) != null) {
				callBackMap.get(AUTH_CMD_SETPWDPROTECTION).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_GETPWDPROTECTION_OK:
		case AUTH_GETPWDPROTECTION_ERR:
		case AUTH_GETPWDPROTECTION_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_GETPWDPROTECTION) != null) {
				callBackMap.get(AUTH_CMD_GETPWDPROTECTION).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_GETPWDPROTECTIONTYPE_OK:
		case AUTH_GETPWDPROTECTIONTYPE_ERR:
		case AUTH_GETPWDPROTECTIONTYPE_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_GETPWDPROTECTION) != null) {
				callBackMap.get(AUTH_CMD_GETPWDPROTECTION).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_GETPWDPROTECTION_ME_OK : // 获取自己密保问题列表
		case AUTH_GETPWDPROTECTION_ME_ERR :
		case AUTH_GETPWDPROTECTION_ME_TIMEOUT :
			if (callBackMap.get(AUTH_CMD_GETPWDPROTECTION_ME) != null) {
				callBackMap.get(AUTH_CMD_GETPWDPROTECTION_ME).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_CHANGEPWDPROTECTION_OK:
		case AUTH_CHANGEPWDPROTECTION_ERR:
		case AUTH_CHANGEPWDPROTECTION_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_CHANGEPWDPROTECTION) != null) {
				callBackMap.get(AUTH_CMD_CHANGEPWDPROTECTION).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_GETPWD_OK:
		case AUTH_GETPWD_ERR:
		case AUTH_GETPWD_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_GETPWD) != null) {
				callBackMap.get(AUTH_CMD_GETPWD).Callback(result, resultdata, obj);
				return;
			}
			break;
		case AUTH_CHANGEPWD_OK:
		case AUTH_CHANGEPWD_ERR:
		case AUTH_CHANGEPWD_TIMEOUT:
			if (callBackMap.get(AUTH_CMD_CHANGEPWD) != null) {
				callBackMap.get(AUTH_CMD_CHANGEPWD).Callback(result, resultdata, obj);
				return;
			}
			break;
		}
		CallbackBroadCast(result, resultdata, obj);
	}

	private byte[] tp_auth_get_signindata(String username, String password) {
		String pwd = SkyUtil.Base64encode(password);
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_hsman, UserInfo.getHsman());
		map.put(ProtocolType.Key.TP_TAG_hstype, UserInfo.getHstype());
		map.put(ProtocolType.Key.TP_TAG_imsi, UserInfo.getImsi());
		map.put(ProtocolType.Key.TP_TAG_imei, UserInfo.getImei());
		map.put(ProtocolType.Key.TP_TAG_mem, "" + UserInfo.getMem());
		map.put(ProtocolType.Key.TP_TAG_vmver, "" + UserInfo.getCurrentapiVersion());
		map.put(ProtocolType.Key.TP_TAG_plat, "" + 10);
		// map.put(ProtocolType.Key.TP_TAG_et,SCREEN_ENTRY);
		map.put(ProtocolType.Key.TP_TAG_hsver, "460000123456789");
		map.put(ProtocolType.Key.TP_TAG_w, "" + UserInfo.getSrcw());
		map.put(ProtocolType.Key.TP_TAG_h, "" + UserInfo.getSrch());
		map.put(ProtocolType.Key.TP_TAG_appid, "" + UserInfo.getAppid());
		map.put(ProtocolType.Key.TP_TAG_appver, "" + UserInfo.getAppver());
		map.put(ProtocolType.Key.TP_TAG_lan, UserInfo.getLang());
		map.put("lanstr", UserInfo.getLang());
		map.put(ProtocolType.Key.TP_TAG_user, username);
		// map.put(ProtocolType.Key.TP_TAG_pnum, buddyinfo.getPnum());
		map.put(ProtocolType.Key.TP_TAG_pwd, pwd);
		data = tp_packet_putdata(map);
		return data;
	}

	private SendNode tp_auth_get_nextsendnode(int cmd, int timeout, byte[] data, DataCallBack callBack) {
		ProtocolList list = getProtocolPacketSendList();
		SendNode node = list.tp_data_get_sendnode(cmd, timeout, data, callBack);
		return node;
	}

	private void tp_auth_senddata_cmn_pre(int cmd, int timeout, byte[] data, DataCallBack callBack) {
		tp_auth_senddata_cmn_real(cmd, timeout, data, false, callBack);
	}

	private void tp_auth_senddata_cmn(int cmd, int timeout, byte[] data, DataCallBack callBack) {
		tp_auth_senddata_cmn_real(cmd, timeout, data, true, callBack);
	}

	private void tp_auth_senddata_cmn_real(int cmd, int timeout, byte[] data, boolean isappend, DataCallBack callBack) {
		ProtocolList list = getProtocolPacketSendList();
		if (!isRun) {
			tp_auth_start();
		}
		if (isappend)
			list.tp_data_append_send(cmd, timeout, data, callBack);
		else
			list.tp_data_prepend_send(cmd, timeout, data, callBack);
	}

	/**
	 * 采用MD5加密算法，将任意长度字符串加密
	 * 
	 * @param String
	 * @return String
	 * @throws NoSuchAlgorithmException
	 * @throws Exception
	 */

	private void tp_auth_rspchstr(int cmd, String chstr) {
		String rsp1;
		String rsp2;
		try {
			rsp1 = SkyUtil.encryptByMD5(chstr + UserInfo.getImsi());
			rsp2 = SkyUtil.Base64encode(UserInfo.getImsi());
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
		LogManager.LogShow("TpAuth", "tp_auth_rspchstr chstr= " + chstr);
		byte[] data = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put(ProtocolType.Key.TP_TAG_rspstr1, rsp1);
		map.put(ProtocolType.Key.TP_TAG_rspstr2, rsp2);

		data = tp_packet_putdata(map);
		tp_auth_senddata_cmn_pre(cmd, ProtocolType.TP_TIMOUT, data, null);
	}

	private void auth_packet_process(TpPacket pkt) {
		RspData rspdata = new RspData();
		rspdata.setSubid(pkt.getSubid());
		LogManager.LogShow("TpAuth", "auth_packet_process pkt.getService()= " + pkt.getService() + "pkt.getSubid() = " + pkt.getSubid());
		if (pkt.getService() != ProtocolType.ServerId.TP_SERVICE_AUTH) {
			// 出错处理
			return;
		}

		Map<String, String> map = pkt.getHash();
		Set<String> set = map.keySet();
		switch (pkt.getSubid()) {
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETTIPTEMPLATE:
		{
			LinkedList<KeyValue> list = pkt.getList();
			int i=0;
			for (KeyValue kv : list) {
				String key = kv.key;
				String value = kv.value;
				if (key.equals(ProtocolType.Key.TP_TAG_msg)){
					if(i<5){
						tips[i] = new String(value);
					}
					i++;
				}
			}
		}
			break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETSKYID:/** < . */
		{// 注册，登录
			String chstr = null;
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_chstr))
					chstr = value;
				else if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
			}
			LogManager.LogShow("TpAuth", "chstr" + chstr);
			if (chstr != null) {
				tp_auth_rspchstr(ProtocolType.AuthType.TP_SUBSERVICE_AUTHRSP_GETSKYID, chstr);
			} else {
				Callback(AUTH_GETSKYID_ERR, rspdata, null);
				// AUTH_CB_EVENT(pAuth,AUTH_GETSKYID_ERR,&rspdata->common_data,0);
			}
		}
			break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTHRSP_GETSKYID:/** < . */
		{
			int skyid = 0;
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_skyid))
					skyid = Integer.parseInt(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
			}
			LogManager.LogShow("TpAuth", "TP_SUBSERVICE_AUTHRSP_GETSKYID errcode" + rspdata.getErrcode() + "skyid " + skyid);
			if (skyid != 0) {
				if (null == this.nextnode) {// /隐藏注册成功，即通过imsi获取skyid，需要app保存该skyid
					Callback(AUTH_SIGUP_IMPLICIT_OK, rspdata, new Integer(this.skyid));
				} else {
					this.skyid = skyid;
					LogManager.LogShow("TpAuth", "this.nextnode.getCmd()=" + this.nextnode.getCmd() + this.nextnode + this.nextnode.getCallBack());
					tp_auth_senddata_cmn(this.nextnode.getCmd(), ProtocolType.TP_TIMOUT, this.nextnode.getData(), this.nextnode.getCallBack());
					this.nextnode = null;
					// Callback(AUTH_GETSKYID_OK, rspdata, null);
				}
			} else {
				Callback(AUTH_GETSKYID_ERR, rspdata, null);
				if (null == this.nextnode) {
					Callback(AUTH_SIGUP_IMPLICIT_ERR, rspdata, null);
				}
			}
		}
			break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNUP:/** < . */
		{
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
			}
			LogManager.LogShow("TpAuth", "TP_SUBSERVICE_AUTH_SIGNUP errcode" + rspdata.getErrcode());
			if (rspdata.getErrcode() == ProtocolType.TP_ERRCODE_OK) {
				Callback(AUTH_SIGUP_EXPLICIT_OK, rspdata, new Integer(this.skyid));
			} else {
				Callback(AUTH_SIGUP_EXPLICIT_ERR, rspdata, null);
			}
		}
			break;
		// case ProtocolType.AuthType.TP_SUBSERVICE_AUTHRSP_SIGNUP:/** < . */
		// break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SIGNIN:/** < . */
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETICONSTR: {
			String icon_str = "";
			String ip_str = "";
			String token_str = "";
			int skyid = -1, w = 0, h = 0, type = 0;
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_token))
					token_str = value;
				else if (key.equals(ProtocolType.Key.TP_TAG_aicon))
					icon_str = value;
				else if (key.equals(ProtocolType.Key.TP_TAG_aiconw))
					w = Integer.parseInt(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_aiconh))
					h = Integer.parseInt(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_aicontype))
					type = Integer.parseInt(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_ip))
					ip_str = value;
				else if (key.equals(ProtocolType.Key.TP_TAG_skyid))
					skyid = Integer.parseInt(value);

			}
			if (token_str.length()>0&&ip_str.length()>0) {
				AuthServeripData data = new AuthServeripData();
				data.setToken(token_str);
				data.setIp(ip_str);
				LogManager.LogShow("TpAuth", "AuthServeripData skyid = " + skyid);
				data.setSkyid(this.skyid);
				if (skyid != -1)
					data.setSkyid(skyid);
				LogManager.LogShow("TpAuth", "AuthServeripData skyid = " + data.getSkyid());
				if (this.skyid != 0) {// 如果隐式登录的话，skyid肯定有值
					Callback(AUTH_SIGIN_IMPLICIT_OK, rspdata, data);
				} else {
					Callback(AUTH_SIGIN_EXPLICIT_OK, rspdata, data);
				}
				if (skyid != -1)
					this.skyid = skyid;
			} else if (icon_str.length()>0) {
				BmpData bst = new BmpData();
				byte[] p;
				bst.setW(w); 
				bst.setH(h);
				bst.setType(type);

				p = Base64.decode(icon_str, Base64.DEFAULT);
				bst.setBuflen(p.length);
				bst.setP(p);
				Callback(AUTH_SIGIN_EXPLICIT_WAITING, rspdata, bst);
			} else {
				if (this.skyid != -1&&this.skyid != 0) {// 如果隐式登录的话，skyid肯定有值
					Callback(AUTH_SIGIN_IMPLICIT_ERR, rspdata, null);
				} else {
					Callback(AUTH_SIGIN_EXPLICIT_ERR, rspdata, null);
				}
			}
		}
			break;
		// case TP_SUBSERVICE_AUTHRSP_SIGNIN:/**< . */
		// case TP_SUBSERVICE_AUTH_SIGNOUT:/**< . */
		// break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWDPROTECTION:// 请求密保问题列表
		{
			pwdprotection_list.clear();
			LinkedList<KeyValue> list = pkt.getList();
			for (KeyValue kv : list){
				String key = kv.key;
				String value =  kv.value;
				if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_qstr)) {
					if (value.length() > 0) {
						pwdprotection_list.add(value);
					}
				}
			}
			if (rspdata.getErrcode() != ProtocolType.TP_ERRCODE_OK)
				Callback(AUTH_GETPWDPROTECTION_ERR, rspdata, null);
			else{
				Callback(AUTH_GETPWDPROTECTION_OK, rspdata, pwdprotection_list);
			}
			break;
		}
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWDPROTECTION_ME:// 
		{
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
				else if (key.equals(ProtocolType.Key.TP_TAG_qstr)){
					me_qstr = value;
				}else if (key.equals(ProtocolType.Key.TP_TAG_email)){
					me_email = value;
				}
			}
			if (rspdata.getErrcode() != ProtocolType.TP_ERRCODE_OK)
				Callback(AUTH_GETPWDPROTECTION_ME_ERR, rspdata, null);
			else
				Callback(AUTH_GETPWDPROTECTION_ME_OK, rspdata, null);
		}
			break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETPWDPROTECTION:// 密保验证,密保设置
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWDPROTECTION:// 更改密保
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWD:// 通过密保找回密码
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWD:// 用户密码修改
		{
			for (String key : set) {
				String value = map.get(key);
				if (key.equals(ProtocolType.Key.TP_TAG_err))
					rspdata.setErrcode(Integer.parseInt(value));
				else if (key.equals(ProtocolType.Key.TP_TAG_errstr))
					rspdata.setString(value);
			}
			if (rspdata.getErrcode() == ProtocolType.TP_ERRCODE_OK) {
				if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETPWDPROTECTION) {
					Callback(AUTH_SETPWDPROTECTION_OK, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWDPROTECTION) {
					Callback(AUTH_CHANGEPWDPROTECTION_OK, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWD) {
					Callback(AUTH_GETPWD_OK, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWD) {
					Callback(AUTH_CHANGEPWD_OK, rspdata, null);
				}
			} else {
				if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_SETPWDPROTECTION) {
					Callback(AUTH_SETPWDPROTECTION_ERR, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWDPROTECTION) {
					Callback(AUTH_CHANGEPWDPROTECTION_ERR, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWD) {
					Callback(AUTH_GETPWD_ERR, rspdata, null);
				} else if (pkt.getSubid() == ProtocolType.AuthType.TP_SUBSERVICE_AUTH_CHANGEPWD) {
					Callback(AUTH_CHANGEPWD_ERR, rspdata, null);
				}

			}

		}
			break;
		case ProtocolType.AuthType.TP_SUBSERVICE_AUTH_GETPWDPROTECTIONTYPE:// 请求密保类型
		{
			// #if 0
			// AUTH_PWDPROTECTION_DATA nodeData[5] = {0};
			// AUTH_PWDPROTECTION_DATA*node = NULL;
			// GList *Qlist = NULL;
			// int index = 0;
			// while (l) {
			// pair = l->data;
			// if(0 == strcmp(pair->keystr,TP_TAG_err)){
			// rspdata->common_data.errcode = atoi(pair->value);
			// }else if(0 == strcmp(pair->keystr,TP_TAG_errstr)){
			// rspdata->common_data.string = ((gchar *) pair->value);
			// } else if(0 == strcmp(pair->keystr,TP_TAG_protectiontype)){
			// if( pair->value[0]){
			// if(index >=4) break;
			// node = &nodeData[index++];
			// node->type = atoi(pair->value);
			// }
			// } else if(0 == strcmp(pair->keystr,TP_TAG_protectiontypestring)){
			// if( pair->value[0]){
			// node->typestr = pair->value;
			// Qlist = g_list_append(Qlist, node);//不malloc
			// }
			// }
			// l = l->next;
			// }
			// if(Qlist){
			// AUTH_CB_EVENT(pAuth,AUTH_GETPWDPROTECTIONTYPE_OK,&rspdata->common_data,(int32)Qlist);
			// while(Qlist)
			// Qlist = g_list_remove(Qlist, Qlist->data);
			// }
			// else{
			// AUTH_CB_EVENT(pAuth,AUTH_GETPWDPROTECTIONTYPE_ERR,&rspdata->common_data,0);}
			// #endif

		}
			break;
		default:
			Callback(AUTH_UNKOWN_ERR, rspdata, null);
			break;
		}
	}
}